{extend name="common/layout"}

{block name="body_tag_class"}layui-layout-body pear-admin{/block}

{block name="main"}
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
	<!-- 顶 部 样 式 -->
	<div class="layui-header">
		<!-- 菜 单 顶 部 -->
		<div class="layui-logo">
			<!-- 图 标 -->
			<img class="logo">
			<!-- 标 题 -->
			<span class="title"></span>
		</div>
		<!-- 顶 部 左 侧 功 能 -->
		<ul class="layui-nav layui-layout-left">
			<li class="collapse layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
			<li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading = 600></a></li>
		</ul>
		<!-- 多 系 统 菜 单 -->
		<div id="control" class="layui-layout-control"></div>
		<!-- 顶 部 右 侧 菜 单 -->
		<ul class="layui-nav layui-layout-right">
			<!-- <li class="layui-nav-item layui-hide-xs"><a href="#" class="menuSearch layui-icon layui-icon-search"></a></li> -->
			<li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
			<!-- <li class="layui-nav-item layui-hide-xs"><a href="/" class="layui-icon layui-icon-website"></a></li> -->
			<!-- <li class="layui-nav-item layui-hide-xs message"></li> -->
			<li class="layui-nav-item user">
				<!-- 头 像 -->
				<a class="layui-icon layui-icon-username" href="javascript:;"></a>
				<!-- 功 能 菜 单 -->
				<dl class="layui-nav-child">
					<dd><a  href="javascript:;" >{:get_admin_info()['name']}</a></dd>
					<!-- <dd><a user-menu-url="view/system/person.html" user-menu-id="5555" user-menu-title="基本资料">基本资料</a></dd> -->
					<dd><a href="javascript:void(0);" id="updpwd" class="updpwd">修改密码</a></dd>
					<dd><a href="javascript:void(0);" class="logout">退出登录</a></dd>
				</dl>
			</li>
			<!-- 主 题 配 置 -->
			<li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
		</ul>
	</div>
	<!-- 侧 边 区 域 -->
	<div class="layui-side layui-bg-black">
		<!-- 菜 单 顶 部 -->
		<div class="layui-logo">
			<!-- 图 标 -->
			<img class="logo">
			<!-- 标 题 -->
			<span class="title"></span>
		</div>
		<!-- 菜 单 内 容 -->
		<div class="layui-side-scroll">
			<div id="sideMenu"></div>
		</div>
	</div>
	<!-- 视 图 页 面 -->
	<div class="layui-body">
		<!-- 内 容 页 面 -->
		<div id="content"></div>
	</div>
	<!-- 页脚 -->
	<div class="layui-footer layui-text">
				<span class="left">
					Released under the MIT license.
				</span>
		<span class="center"></span>
		<span class="right">
					Copyright © 2021-2022 admin
				</span>
	</div>
	<!-- 遮 盖 层 -->
	<div class="pear-cover"></div>
	<!-- 加 载 动 画 -->
	<div class="loader-main">
		<!-- 动 画 对 象 -->
		<div class="loader"></div>
	</div>
</div>
<!-- 移 动 端 便 捷 操 作 -->
<div class="pear-collapsed-pe collapse">
	<a href="#" class="layui-icon layui-icon-shrink-right"></a>
</div>

{/block}

{block name="footer_script"}
<script>
	layui.use(['admin','jquery','popup','drawer','element','layer','common'], function() {
		var $ = layui.jquery;
		var admin = layui.admin;
		var popup = layui.popup;
		var layelement = layui.element;
		var common = layui.common;

		//admin.setConfigType("yml");
		//admin.setConfigPath("/pearadmin/config/pear.config.yml");

		admin.render({
			"logo": {
				"title": "Admin",
				"image": "/pearadmin/admin/images/logo.png"
			},
			"menu": {
				"data": "/admin/index/menu",
				"method": "GET",
				"accordion": true,
				"collapse": false,
				"control": false,
				"controlWidth": 500,
				"select": "0",
				"async": true
			},
			"tab": {
				"enable": true,
				"keepState": true,
				"session": true,
				"preload": false,
				"max": "30",
				"index": {
					"id": "0",
					"href": "/admin/index/main",
					"title": "首页"
				}
			},
			"theme": {
				"defaultColor": "1",
				"defaultMenu": "dark-theme",
				"defaultHeader": "light-theme",
				"allowCustom": true,
				"banner": false
			},
			"colors": [
				{
					"id": "1",
					"color": "#2d8cf0",
					"second": "#ecf5ff"
				},
				{
					"id": "2",
					"color": "#36b368",
					"second": "#f0f9eb"
				},
				{
					"id": "3",
					"color": "#f6ad55",
					"second": "#fdf6ec"
				},
				{
					"id": "4",
					"color": "#f56c6c",
					"second": "#fef0f0"
				},
				{
					"id": "5",
					"color": "#3963bc",
					"second": "#ecf5ff"
				}
			],
			"other": {
				"keepLoad": "0",
				"autoHead": false,
				"footer": false
			},
			"header": {
				"message": "" ///pearadmin/admin/data/message.json
			}
		});


		$("#updpwd").click(function(){
			layer.open({
				type: 2,
				title: '修改密码',
				shade: 0.1,
				area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'400px'],
				content: '/admin/admin/updpwd'
			});
		});

		// 登出逻辑
		admin.logout(function(){


			layer.confirm('确认退出登录吗?', {
						btn: ['确认','取消'] //按钮
					}, function(){

						$.ajax({
							url: '/admin/index/logout',
							type: "GET",
							data: {},
							success: function (res) {
								console.log(res);
								if (res.code == 1) {

									layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
										location.href = "/admin/public/login";
									})

								} else {
									layer.msg(res.msg, { icon: 2, time: 2000 }, function () {
									})
								}

								layer.closeAll('loading');
							}
						});
					}, function(){

					}
			);





			// popup.success("注销成功",function(){
			// 	location.href = "/admin/public/login";
			// })
			// 注销逻辑 返回 true / false
			//return true;
		})

		// 消息点击回调
		admin.message(function(id, title, context, form) {});
	})
</script>
{/block}